package com.itheima.ydd.common;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * @author yan.zhou
 * @date 2022/2/5
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PageResult implements Serializable {
    //总条数
    private Long count;
    //当前页数
    private Long currentPage;
    //页大小
    private Long pageSize;
    //总页数
    private Long totalPages;

    private List data;


    public static <T> PageResult init(Page<T> pageInfo){

        return new PageResult(pageInfo.getTotal(), pageInfo.getPages(), pageInfo.getSize(), pageInfo.getCurrent(), pageInfo.getRecords());
    }
}
